package com.itheima.dao;

import com.itheima.entity.Result;
import com.itheima.pojo.OrderSetting;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface OrderSettingDao {

    @Insert("insert into t_ordersetting (id,orderDate,number,reservations) values(#{id},#{orderDate},#{number},0)")
    public Integer insert(OrderSetting orderSetting);

    @Select("select * from t_ordersetting where orderDate= STR_TO_DATE(#{orderDate},'%Y/%m/%d')")
    public OrderSetting findByDate(String orderDate);

    @Select("select * from t_ordersetting where orderDate= STR_TO_DATE(#{orderDate},'%Y-%m-%d')")
    public OrderSetting findByDate1(String orderDate);

    @Update("update t_ordersetting set number=#{number} where orderDate=STR_TO_DATE(#{orderDate},'%Y/%m/%d')")
    public Integer updateByOrderDate(@Param("orderDate") String date,@Param("number") Integer number);

    @Select("select * from t_ordersetting where orderDate between STR_TO_DATE(#{startDate}, '%Y-%m-%d') and STR_TO_DATE(#{endDate}, '%Y-%m-%d')")
    public List<OrderSetting> getOrderSettingByMonth(@Param("startDate") String startDate,@Param("endDate") String endDate);

    @Update("update t_ordersetting set number=#{number} where orderDate=#{orderDate}")
    public Integer editNumberByDate(OrderSetting orderSetting);

    @Select("select * from t_ordersetting where orderDate= #{orderDate}")
    public OrderSetting findByStringDate(Date orderDate);

    @Update("update t_ordersetting set reservations=#{reservations} where orderDate=#{orderDate}")
    public Integer updateNumberAndReservations(OrderSetting orderSetting);

    @Select("select reservations from t_ordersetting where orderDate = #{date}")
    public Integer findOrderCountByDate(String date);
}
